﻿using System;
using System.Linq;
using System.Threading;

using XcoAppSpaces.Contracts.Worker;
using XcoAppSpaces.Core;
using Microsoft.Ccr.Core;
using XcoAppSpaces.Contracts.Exceptions;
using XcoAppSpaces.Core.Configuration;
using XcoAppSpaces.Transport.Sockets;
using System.Net;

namespace test.XcoAppSpaces.Core
{
	#region Test Worker and Contract
	public class TestWorkerContract : PortSet<int, string, PortSet<int, string>, bool>
	{
		public AutoResetEvent are = new AutoResetEvent(false);
	}

	class MyTestWorker : TestWorkerContract
	{
		public int intMsg;
		public string strMsg;

		[XcoExclusive]
		public void ProcessInt(int msg)
		{
			this.intMsg = msg;
		}

		[XcoConcurrent]
		public void ProcessString(string msg)
		{
			this.strMsg = msg;
		}

		[XcoConcurrent]
		public void ProcessPort(PortSet<int, string> msg)
		{
			msg.Post(intMsg); //post back last posted integer
		}

		[XcoTeardown]
		public void ProcessBool(bool msg)
		{
			base.are.Set();
		}
	}

	#endregion
}
